<template>
  <div>
    <!-- 对话框 -->
    <a-modal v-model:visible="visible" title="修改参数" @ok="handleOk">
      <div>
        <p>{{ updateData.remark }}:</p>
        <a-input v-model:value="updateData.value" />
      </div>
    </a-modal>
    <!-- 表格 -->
    <a-table
      :columns="columns"
      :data-source="historyData"
      :loading="loading"
      :pagination="historyPagination"
      :rowKey="(record) => record.id"
      @change="historyChange"
      bordered
    >
      <template #id="id">
        <a @click="updateValue(id)"> 编辑 </a>
      </template>
    </a-table>
  </div>
</template>

<script lang="ts">
import Vue, { defineComponent, reactive, toRefs } from "vue";
import { history } from "./hosk";
export default defineComponent({
  setup() {
    const {
      state,
      getHistory,
      change,
      historyChange,
      formatDate,
      updateValue,
    } = history();
    getHistory();
    return {
      columns,
      change,
      getHistory,
      historyChange,
      formatDate,
      updateValue,
      ...toRefs(state),
    };
  },
});
const columns = [
  {
    title: "名称",
    key: "名称",
    dataIndex: "remark",
    align: "center",
  },
  {
    title: "实际值",
    key: "value",
    dataIndex: "value",
    align: "center",
  },
  {
    title: "操作",
    key: "编辑",
    dataIndex: "id",
    slots: { customRender: "id" },
    align: "center",
  },
];
</script>

<style lang="less" scoped>
.table {
  width: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  background-color: #121c30;
}

.head {
  display: flex;
  width: 300px;
  justify-content: space-between;
  margin-top: -30px;
  margin-bottom: 30px;

  button {
    width: 120px;
    height: 40px;
    font-size: 22px;
  }
}

.on {
  color: #40a9ff;
}

.off {
  color: rgb(47, 45, 45);
}

.col {
  color: red;
}
</style>
